\pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f0\b0\i0\ulnone\fs28\fc0\cf0 Q: I am using the Windows submenu. For each new window document that I create in my application, a new menu cell is added to the submenu with the window's title and a small X at the left-most edge of the menu cell. How do I programmatically control this X to make it broken when the document associated with the menu cell has been changed?\
\
A: The window method
\f1\fs24 setDocEdited: (BOOL)flag
\f0\fs28 is responsible for displaying the broken X when it is set to YES. This method controls both the X in the menu cell, and the X on the upper right corner of the window. It has to be reset to NO
\b before saving the document
\b0 , so that the X reappears as non-broken. See the code snippet below:\
/* In the case of a text object for example,this text delegate method is responsible for notifying that the document has changed. Please note that ruler and font changes as well as changes caused by spell checking the Text are not reflected by this text delegate method.\
/* After setting setDocEdited to YES, the state of isDocEdited is YES. You can query this state and, if appropriate, display an alert panel before the window closes. Note the use of NXStringTable here for ease of localization. Please refer to our user interface guidelines and release notes for more details.\
\
*/\
\
#define SAVE NX_ALERTDEFAULT\
#define CLOSE NX_ALERTALTERNATE\
#define CANCEL NX_ALERTOTHER\
\
- windowWillClose:sender\
\{\
int result;\
\
if ([currentDocWindow isDocEdited]) \{\
if (!stringTable)\
stringTable = [[NXApp delegate] stringTable];\
result = NXRunAlertPanel([NXApp appName],\
[stringTable valueForStringKey:\
"The document %s has unsaved changes.\\nClose anyway?"],\